#%RAML 1.0 Library
uses:
  constraints: constraint.raml
  label: label.raml
  strings: stringTypes.raml
  pragma: pragma.raml
  secrets: secrets.raml

types:
  CSICapability:
    type: object
    properties:
      accessMode:
        type: string
        enum: [ SINGLE_NODE_WRITER , SINGLE_NODE_READER_ONLY , MULTI_NODE_READER_ONLY , MULTI_NODE_SINGLE_WRITER , MULTI_NODE_MULTI_WRITER ]
        description: |
          * `SINGLE_NODE_WRITER`       - Can only be published once as read/write on a single node, at any given time.
          * `SINGLE_NODE_READER_ONLY`  - Can only be published once as readonly on a single node, at any given time.
          * `MULTI_NODE_READER_ONLY`   - Can be published as readonly at multiple nodes simultaneously.
          * `MULTI_NODE_SINGLE_WRITER` - Can be published at multiple nodes simultaneously. Only one of the node can be used as read/write. The rest will be readonly.
          * `MULTI_NODE_MULTI_WRITER`  - Can be published as read/write at multiple nodes simultaneously.
      accessType:
        type: string
        enum: [ block, mount ]
        description: Indicates whether a block volume with no FS, or a mount volume is to be obtained. The optional fields fsType and mountFlags
      fsType?:
        type: string
        description: |
          Applies only to mount type volumes. The filesystem type. An empty string is equal to an unspecified field value. Optional.
      mountFlags?:
        type: array
        description: |
          Applies only to mount type volumes. The mount options that can be used for the volume. The total size SHALL NOT exceed 4 KiB.
        items:
          type: string
        (pragma.omitEmpty):


  CSIExternalVolumeInfoOptions:
    type: object
    properties:
      pluginName:
        type: string
        minLength: 1
        description: The name of the CSI plugin
      capability:
        type: CSICapability
      nodeStageSecret?:
        type: label.KVLabels
        description: |
          The secrets needed for staging the volume. For example:
           ```
          {
            "username": "MY_USERNAME_SECRET_REFERENCE_NAME",
            "password": "MY_PASSWORD_SECRET_REFERENCE_NAME",
          }
          ```
        (pragma.omitEmpty):
      nodePublishSecret?:
        type: label.KVLabels
        description: |
          The secrets needed for publishing the volume
          ```
          {
            "username": "MY_USERNAME_SECRET_REFERENCE_NAME",
            "password": "MY_PASSWORD_SECRET_REFERENCE_NAME",
          }
          ```
        (pragma.omitEmpty):
      volumeContext?:
        type: label.KVLabels
        description: |
          Static properties of the volume
          * SHOULD NOT contain sensitive information
          * SHOULD NOT be used for uniquely identifying a volume. The `name` alone SHOULD be sufficient to identify the volume
          * A volume uniquely identified by `name` SHALL always report the same volume_context
        (pragma.omitEmpty):
  CSIExternalVolumeInfo:
    type: object
    properties:
      name:
        type: string
        description: A unique identifier for the volume
      provider:
        type: string
        description: The name of the volume provider
        enum: [ csi ]
      options:
        type: CSIExternalVolumeInfoOptions

  DVDIExternalVolumeInfo:
    type: object
    properties:
      size?:
        type: integer
        format: int64
        minimum: 0
        description: The size of the external volume in GiB
      name?:
        type: string
        description: The name of the volume
      provider?:
        type: string
        description: The name of the volume provider
      options?:
        type: label.KVLabels
        (pragma.omitEmpty):
        description: Provider specific volume configuration options
      shared?:
        type: boolean
        default: false
        description: If true, excludes this volume from the global unique volume name check
  PersistentVolumeType:
    type: string
    description: |
      The type of mesos disk resource to use; defaults to root if no profile name is specified.
      When specififying a profileName, this will default to mount.
    enum: [ root, path, mount ]
  PersistentVolumeInfo:
    type: object
    properties:
      type?:
        type: PersistentVolumeType
      size:
        type: integer
        format: int64
        minimum: 0
        description: The size of the persistence volume in MB.
      maxSize?:
        type: integer
        format: int64
        minimum: 0
        description: |
          For `mount` mesos disk resources, the optional maximum size of an exclusive mount volume to be considered.
      profileName?:
        type: string
        description: |
          The storage volume profile. Only volumes with the specified profile are used to launch an application.
          It this option is not given, any volume (with or without a profile) will be used for launching.
      constraints?:
        type: constraints.VolumeConstraint[]
        description: |
          Constraints restricting where new persistent volumes should be created.
          Currently, it is only possible to constrain the path of the disk resource by regular expression.
        uniqueItems: true

  PodEphemeralVolume:
    type: object
    properties:
      name:
        type: strings.Name
        description: The name of the volume to reference.
  ExternalVolumeInfo: (DVDIExternalVolumeInfo | CSIExternalVolumeInfo)
  AppExternalVolume:
    type: object
    properties:
      containerPath:
        type: string
        minLength: 1
        description: The path of the volume in the container
      external: ExternalVolumeInfo
      mode:
        type: strings.ReadMode
        description: Possible values are RO for ReadOnly and RW for Read/Write
  AppHostVolume:
    type: object
    properties:
      containerPath:
        type: string
        minLength: 1
        description: The path of the volume in the container
      hostPath:
        type: string
        minLength: 1
        description: The path of the volume on the host
      mode:
        type: strings.ReadMode
        description: Possible values are RO for ReadOnly and RW for Read/Write
  PodHostVolume:
    type: object
    properties:
      name:
        type: strings.Name
        description: The name of the volume to reference.
      host:
        type: string
        description: |
          Absolute path of the file or directory on the agent, or else the relative
          path of the directory in the executor's sandbox.
          Host volumes are useful for mapping directories that exist on the agent apriori,
          or within the executor sandbox. No resources (Mesos or otherwise) are allocated for
          these types of volumes.
  AppPersistentVolume:
    type: object
    properties:
      containerPath:
        type: string
        minLength: 1
        description: The path of the volume in the container
      persistent: PersistentVolumeInfo
      mode:
        type: strings.ReadMode
        description: Possible values are RO for ReadOnly and RW for Read/Write
  PodPersistentVolume:
    type: object
    properties:
      name:
        type: string
        minLength: 1
        description: Name of the pod level volume
      persistent: PersistentVolumeInfo
  AppSecretVolume:
    type: object
    properties:
      containerPath:
        type: string
        minLength: 1
        description: The path of the secret in the container
      secret:
        type: string
        minLength: 1
        description: References the secret that is used by this volume
  PodSecretVolume:
    type: object
    properties:
      name:
        type: string
        minLength: 1
        description: Name of the pod level volume
      secret:
        type: string
        minLength: 1
        description: References the secret that is used by this volume

  VolumeMount:
    type: object
    properties:
      name:
        type: strings.Name
        description: The name of the volume to reference.
      mountPath:
        type: strings.Path
        description: The path inside the container at which the volume is mounted.
      readOnly?:
        type: boolean

  AppVolume:
    type: AppPersistentVolume | AppExternalVolume | AppSecretVolume | AppHostVolume
  PodVolume:
    type: PodPersistentVolume | PodSecretVolume | PodHostVolume | PodEphemeralVolume
